<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%@page import="dto.UserDTO"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registrar Usuario</title>
 <script type="text/javascript" src="js/jquery-1.8.2.js"></script>
</head>
<body>
	<%
	UserDTO c = (UserDTO)request.getAttribute("usuario");
	String id = null;
	if(c!=null){
		id = String.valueOf(c.getId());	
	}
	String successMsg = "";
	if(!String.valueOf(request.getAttribute("successMsg")).equals("") && request.getAttribute("successMsg")!=null){
		successMsg=String.valueOf(request.getAttribute("successMsg"));
	}
	
	%>
	<form id="registrarForm">
	
	        <div class="box">
                    <table class="ink-table">
                        <thead>
                            <tr>
                                <th style="background-color: #1C70C2; color:white;">ID</th>
                                <th style="background-color: #1C70C2; color:white;">Usuario</th>
                                <th style="background-color: #1C70C2; color:white;">Password</th>
                                 <th style="background-color: #1C70C2; color:white;"></th>
                            </tr>
                        </thead>
                               
                        <tbody>
                        	<tr>
                        		 <td><input size="25" type="hidden" id="id" name="id" value="<%=id!=null?id:""%>"></td>
                        		 <td><input size="25" type="text" id="username" name="username" value="<%=id!=null?c.getUsername():""%>"></td>
                        		 <td><input size="25" type="text" id="password" name="password" value="<%=id!=null?c.getPassword():""%>"></td>
                        		 <td ><input type="submit" value="Registrar Usuario"></td>
                        	</tr>

		
                        </tbody>
                    </table>
        </div>

	</form>
	
<script>


$("#registrarForm").submit(function() {
    var url = "ControladorUser?action=save";
    $.ajax({
           type: "POST",
           url: url,
           data: $("#registrarForm").serialize(), 
           success: function(data)
           {
              
               $(".htmlContent").html(data).hide().fadeIn('slow');
           }
         });

    return false; 
});
 

</script>	
	
</body>
</html>